<?php

class AppController extends Controller {

    public $helpers = array(
        'Html',
        'Form',
        'Session',
        'Time',
        'Javascript'
    );
    public $components = array(
        'Session',
        'Auth',
        'RequestHandler',
        'Session'
    );

    function beforeFilter() {
        //Configure AuthComponent
        $this->Auth->fields = array(
            'username' => 'name',
            'password' => 'password'
        );
        $this->Auth->authorize = 'controller';
        $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
        $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'futures', 'action' => 'index');
        $this->Auth->loginError = __('La contraseña no se corresponde con un usuario', true);
        $this->Auth->authError = __('Permiso denegado', true);
        $this->Auth->userScope = array('User.enabled' => 1, 'User.deleted' => 0);
        $this->Auth->autoRedirect = false;

        if (!$this->Session->read('mostrar_menu_entero')) {
            $this->Session->write('mostrar_menu_entero', 0);
        }

        if ($this->Auth->user()) {
            $this->set('header_nombre_usuario', $this->Auth->user('name'));
            $this->set('header_tipo_usuario', $this->Auth->user('group_id'));
        }
        
        date_default_timezone_set('America/Argentina/Buenos_Aires');
    }

    function isAuthorized() {
        return true;
    }

}

?>